//================================================
//===               Power_sample               ===
//================================================
//使用外部电压基准5v
//================================================
void setup() {
  // put your setup code here, to run once:
   Serial.begin(115200);   //使用115200速率进行串口通讯
   analogReference(EXTERNAL);   //使用外部电压基准
}


#define FILTER_A 0.1
float Value_filter;
float Voltage;
char OK = 1;
void Power_sample()
{
  if(OK==1)
  {
    Value_filter = analogRead(A0)/1024.0*25;
    OK =0;
  }
  Voltage = analogRead(A0)/1024.0*25;
  Value_filter = (float)((float)Voltage * FILTER_A + (1.0 - FILTER_A) * (float)Value_filter);
  Serial.println(Value_filter); // 串口输出
}
void loop() {
  // put your main code here, to run repeatedly:
Power_sample();

}
